<?php

class Globals {
	var $post_vars;
	
	function Globals() {
		$post_vars = $this->StripSlashArray ($_POST);
		if (!is_array($post_vars)) {
			$post_vars = $this->StripSlashArray ($_GET);
		}
		$this->post_vars = $post_vars;		
	}
	// Here are some convenient functions I will use in most of my php programs
	//-----------------------------------------------------------------------------------
	function StripSlashArray ($array)
	{
		array ($new_array);
		
		foreach ($array as $key => $value) {
			$new_array [$key] = stripslashes ($value); 
		}
		
		return $new_array;
	}
	//-----------------------------------------------------------------------------------
	function AddSlashArray ($array)
	{
		array ($new_array);
		
		foreach ($array as $key => $value) {
			$new_array [$key] = addslashes ($value); 
		}
		
		return $new_array;
	}
	//-----------------------------------------------------------------------------------
	function print_array($array) {
		if(gettype($array)=="array") {
			echo "<ul>";
			while (list($index, $subarray) = each($array) ) {
				echo "<li>$index <code>=&gt;</code> ";
				print_array($subarray);
				echo "</li>";
			}
			echo "</ul>";
		} else 
			echo $array;
	}

	//-----------------------------------------------------------------------------------
	#returns one line at a time from a file.

	function get_line ($file) { 
		$read_again = true; 
		$buffer_size = 4096; 
		$full = ""; 
		while ((!feof ($file)) && ($read_again)) { 
			$read_again = false; 
			$line = fgets ($file, $buffer_size); 
			$full .= $line; 
			if (strlen($line) >= ($buffer_size - 1)) { 
				if ($line[($buffer_size - 2)] != '\n') { 
				 $read_again = true; 
				} 
			} 
		} 
		return $full; 
	}
} //end of class
?>
